/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DTO;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 *
 * @author TrongKhoa
 */
public class DatabaseDTO
{
    private String _databaseName;
    Document _document;
    Element _databaseElement;
    private ArrayList<DataTableDTO> _tables;

    public DatabaseDTO(Document document)
    {
        _document = document;
        _databaseElement = _document.getDocumentElement();
        _databaseName = _databaseElement.getAttribute("Name");
        _tables = new ArrayList<>();
        NodeList tables = document.getDocumentElement().getElementsByTagName("Table");

        for (int i = 0; i < tables.getLength(); i++)
        {
            Element tableElement = (Element)tables.item(i);
            _tables.add(new DataTableDTO(tableElement));
        }
    }

    public DatabaseDTO(String _databaseName, ArrayList<DataTableDTO> _tables)
    {
        this._databaseName = _databaseName;
        this._tables = _tables;
    }

    @Override
    public String toString()
    {
        return _databaseName;
    }

    public ArrayList<DataTableDTO> getTables()
    {
        return _tables;
    }

    public void setTables(ArrayList<DataTableDTO> _tables)
    {
        this._tables = _tables;
    }
    
    
}
